import React, { useDebugValue, useState } from "react";


// 自定义hooks：限制最大年龄
function useMaxAge(maxAge){
  const [count, setCount] = useState(6);

  function changeCount() {
    setCount(count+1);
  }

  useDebugValue(count,(state)=>{
    return state>maxAge?"年龄超了":"年龄正常"
  })

  return [count, changeCount];

}


export default function Index() {
  
  const [count, changeCount] = useMaxAge(20);

  return (
    <>
      <div>useDebugValueDemo</div>
      <p>count:{count}</p>
      <input type="button" value="修改count" onClick={changeCount} />
    </>
  );
}
